import formJs from "./regexDetail.js"; //新增弹框配置项
import TableData from "@/components/public/el-table-pagination"; //主页面列表


import {

    getEquipmentUseInfoList, //详情

} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",

    ],
    data() {
        return {
            visible: "",
            loading: false,
            title: null,
            isLock: false,
            dialogHeight: null,
            treeData: [], //材料种类


            btnShow: true,
            currentDetail: null,
            fileList: [],
            tableData: [],
            getList: {
                fId: "",
                startDates: "",
                endDates: "",
                page:1,
                pageSize:20,
            },
            queryCriteriaData: {}, //分页
            navigatepageNums: null,
            table_config: formJs.table_config, //列表
        };
    },
    components: {
        TableData,
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },

        statusNum: {
            handler(newVal) {
                if (newVal) {

                    this.edit(newVal);
                }
            },
            immediate: true,
        },
        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    if (this.statusNum != 1) {
                        this.getList.fId=this.currentDetail.fId
                        this.yj_searchForm(this.getList)
                    }
                }
            },
            immediate: true,
        },
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：
    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
        this.btnShow = true

   
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.5 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        selectChange(data, a, b) {
            console.log(data, a, b);
        },
        edit() {
            this.formData = this.$options.data.call(this).formData;
        },


        // 详情
        yj_searchForm(obj) {
            this.loading = true;
            getEquipmentUseInfoList(obj).then((res) => {
                if (res.errcode == 0) {
                    this.tableData = res.data.pageInfo.list;
                    this.queryCriteriaData = res.data.pageInfo;
                    this.loading = false;

                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }
            });
        },

    },
};